#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "qrencode.h"

#define _width 45

int main(void)
{
	 uint8_t i = 0;
	uint8_t* P_buff;
	OLED_Init();	 
	char qrmsg[] = "I make it!!!152313";	 
	QRcode* qrcode;	
	qrcode = QRcode_encodeString(qrmsg, 7, QR_ECLEVEL_L, QR_MODE_8, 1);
	int x,y=0,a=0;
	uint8_t buff[_width] = {0x00};
	while(y<qrcode->width){
		x=0;
		while(x<qrcode->width){
			P_buff = &buff[x];
			if (qrcode->data[y * qrcode->width + x] & 0x01)
			{ 
				*P_buff |=  (0x01<<a);
			}
			else
			{
			 *P_buff &=  ~(0x01<<a);
			}
			x++;
		}
		
		if(a>=7 || y == qrcode->width-1){
			//dis
			OLED_SetCursor(y/8+2,(128-qrcode->width)/2);
			i=0;
			while(_width>i){
				OLED_WriteData(buff[i]);
				buff[i] = 0x00;
				i++;
			}			 
			a=0;
		}else{
			a++;
		}
		y++;
	}
 
	while (1)
	{
		
	}
}
